"""Helper functions

Consists of functions to typically be used within templates, but also
available to Controllers. This module is available to templates as 'h'.
"""
# Import helpers as desired, or define your own, ie:
#from webhelpers.html.tags import checkbox, password

from webhelpers.html import tags
from webhelpers.html.builder import HTML
from pylons.i18n import lazy_ugettext as _

from chowa.lib.helpers import *
from chowa.model.organization import District
from pubservices.lib.base import Session


def select_district(district_id):
    districts = Session.query(District).all()
    hidden_url = HTML.tag('a', class_="hidden-url", href=url_gen(id='$id'))
    return tags.select('district', [district_id],
                       [(d.id, d.name) for d in districts], class_='active-select')  + hidden_url

def select_service(service):
    hidden_url = HTML.tag('a', class_="hidden-url", href=url_gen(service='$id'))
    return tags.select('service', [service],
                       [('water', _('Water')),
                        ('electricity', _('Electricity')),
                        ('heating', _('Heating')),
                        ('gas', _('Gas'))], class_='active-select') + hidden_url
